package com.future.controller;

import com.future.domain.DTO.PasswordDTO;
import com.future.domain.DTO.UserLoginDTO;
import com.future.domain.Result;

import com.future.service.LoginService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import sun.security.util.Password;

@RestController
public class LoginController {
    @Autowired
    private LoginService loginService;


    @ApiOperation("账号登陆")
    @PostMapping("accountLogin")
    public Result accountLogin(@RequestBody UserLoginDTO user) {
        return loginService.accountLogin(user);
    }

    @ApiOperation("邮箱登陆")
    @PostMapping("emailLogin")
    public Result emailLogin(@RequestBody UserLoginDTO user) {
        return loginService.emailLogin(user);
    }
    
    @ApiOperation("登出")
    @GetMapping("logout")
    public Result logout() {
        return loginService.logout();
    }

    @ApiOperation("忘记密码")
    @PostMapping("forgetPassword")
    public Result forgetPassword(@RequestBody PasswordDTO user) {
        return loginService.forgetPassword(user);
    }
}

